/* eslint-disable */ 
import axios from 'axios' 
import qs from 'qs' 
let domain = '{{&domain}}' 
let axiosInstance = axios.create() 
export const getDomain = () => {
  return domain
}
export const setDomain = ($domain) => {
  domain = $domain
}
export const getAxiosInstance = () => {
  return axiosInstance
}
export const setAxiosInstance = ($axiosInstance) => {
  axiosInstance = $axiosInstance
}
export const request = (method, url, body, queryParameters, form, config)=>{
  method = method.toLowerCase()
  let keys = Object.keys(queryParameters)
  let queryUrl = url
  if ( keys.length > 0 ) {
      queryUrl = url + '?' + qs.stringify(queryParameters)
  }
  // let queryUrl = url+(keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
  if(body){
      return axiosInstance[method](queryUrl,body,config)
  } else if (method === 'get' || method === 'delete' || method === 'head' || method === 'option') {
      return axiosInstance[method](queryUrl,config)
  } else {
      return axiosInstance[method](queryUrl,qs.stringify(form),config)
  }
}
{{> methods }}
